<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>升级代理 - FRM</title>
	<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
	<meta content="yes" name="apple-mobile-web-app-capable" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style" />
	<meta content="telephone=no" name="format-detection" />
     <link href="../Ryancss/upgrade_agent.css" rel="stylesheet" type="text/css"/>
	 
	 		
		<style type="text/css">

	   .display-block{
	   display :block ;
	   }
	   
	   .display-none{
	   display :none ;
	   }
	   
	   
	   
	   
	  .aui-flex-border {
    border-radius: 50px;
    padding: 0;
    background: #f4f3f3;
	
} 
	   
	.aui-flexa {
    display: -webkit-box;
    display: -webkit-flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
	
	margin: 0 auto; 
    width: 90%;
    box-shadow: 0 3px 30px #ff5ba8;
}
 

.aui-flex-box {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: #333;
}


.aui-flex-box input {
    border: none;
    background: none;
    font-size: 0.85rem;
    padding-left: 1.4rem;
    width: 100%;
}


.aui-button-once button {
    background-image: linear-gradient(to bottom,#ff047f,#ff2662);
    background-color: #ff087c;
    box-shadow: 0 0 19px #dd7fe6;
    color: #fff;
    font-size: 0.9rem;
    padding: 0.3rem 1rem;
    border-radius: 20px;
    border: none;
    margin-top: 8px;
    margin-bottom: 8px;
    margin-right: 10px;
}   
	   
	   
	   
	   
	   
		</style>
			
	 
</head>
<body>



<section class="aui-flexView">
            <section class="aui-scrollView">
                <div class="aui-free-head">
                    <div class="aui-flex b-line">
                        <div class="aui-user-img" id="headimgurl">
                            <img src="">
                        </div>
                        <div class="aui-flex-box">
                            <h2 id="username"> </h2>
							
                            <p id="daili_price"> </p>
                        </div>
                        <div class="aui-arrow" onclick="faka_agent()">
                            <p>购买激活码</p>
                        </div>
                    </div> 
                    
					<div class="aui-button">
						<div class="aui-flexa aui-flex-border"> 
                            <div class="aui-flex-box">
                                <input  id="kami"  type="text" placeholder="请输入激活码" >
                            </div>
                            <div class="aui-button-once" onclick="loginOff()">
                                <button>升级代理</button>
                            </div>
                        </div>			
			
					
                </div>

                </div>
				
						

				
				
		
                    <div class="aui-flex-box" id="agent_introduction_picture"> 
									<img src="">
					</div>
         
 
				


            </section>
        </section>
 
</body>

<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript">
    var user_id = localStorage.getItem('user_id');
    var api_url = localStorage.getItem('api_url');
    apiready = function(){
      api.parseTapmode();
	  

/*
		 api.showProgress({
			  title: '加载中',
			  modal: false
		 });
	*/
														  
														  
													
												if (localStorage.getItem('userlogo_Cache') !== '' && localStorage.getItem('userlogo_Cache') !== null){			//  如果头像不为空	  
																		
													headimgurl.innerHTML = '<img src="data:image/png;base64,'+ localStorage.getItem('userlogo_Cache')+'">' ;			
													
												}else {	
													if (localStorage.getItem('headimgurl') !== ''){			//  如果头像不为空
																
															headimgurl.innerHTML = '<img src="'+ localStorage.getItem('headimgurl')+'">' ;					
													}
												}		
																  
														  
	
            								
								
								
																		
							if (localStorage.getItem('nick_name') !== ''){
																		 
									/* 昵 称 */		username.innerHTML = '' + localStorage.getItem('nick_name'); 	
																		
																		
								}else{
																
									/*用 户 名*/	username.innerHTML = '' + localStorage.getItem('user_name'); 		
																		
							}							
							    													  
														  
														  
														  
														  
														  
														  
														  
      GetData();   //获取数据

      var clipBoard = api.require('clipBoard');
      clipBoard.get(function(ret, err) {
          if (ret) {

            if (ret.value.length == localStorage.getItem('kami_length')) {
              var kami = $api.byId('kami');
              kami.value = ret.value;
			  
			  
            /*  api.toast({
                  msg: '智能识别\n\n'+ret.value+'\n\n已为您粘贴',
                  duration: 8000,
                  location: 'middle'
              });
			  */
			  
			  
			  
												var dialogBox = api.require('dialogBox');
												dialogBox.alert({
													texts: {  
														title: '智能识别',
														content: '激活码：'+ret.value+'\n\n是否使用？',
														leftBtnTitle: '取消',
														rightBtnTitle: '确认并使用'
													},
													styles: {
														bg: '#fff',
														w: 300,
														corner:10,
														title: {
															marginT: 20,
															icon: 'widget://Ryanimg/frame0/rrrr.png',
															iconSize: 20,
															titleSize: 14,
															titleColor: '#999'
														},
														content: { 
															marginT: 20,       //（可选项）数字类型；内容文本顶端与标题栏底端的距离，如果标题栏不存在，则是到窗口顶端的距离；默认：20
															marginB: 20,       //（可选项）数字类型；内容文本底端与 left/right 顶端的距离，如果 left/right 都不存在，则是到对话框底端的距离；默认：20
															color: '#999',
															size: 14 
														},
														left: {
															marginB: 30,
															marginL: 30,
															w: 100,
															h: 35,
															corner: 2,
															bg: '#eeeeee',
															color: '#999',  //（可选项）字符串类型；右边按钮标题字体颜色，支持rgb、rgba、#；默认：'#007FFF'
															size: 12
														},
														right: {
															marginB: 30,
															marginL: 40,
															w: 100,
															h: 35,
															corner: 2,
															bg: '#ff1679',
															color: '#fff',  //（可选项）字符串类型；右边按钮标题字体颜色，支持rgb、rgba、#；默认：'#007FFF'
															size: 12
														}
														
														
														
													}
												}, function(ret) {
																			
																				if (ret.eventType == 'left') {
																				
																					//关闭弹窗
																					var dialogBox = api.require('dialogBox');
																					dialogBox.close({
																						dialogName: 'alert'
																					});
																					

																					
																					
																						//清空剪贴板
																					var clipBoard = api.require('clipBoard');
																					clipBoard.set({
																						value: '逐梦影视' 
																					});																				
																					
																																										
																					
																					
																				} else if(ret.eventType == 'right') {
																			
																							loginOff();  //使用激活码
																					
																																     
																					//关闭弹窗
																					var dialogBox = api.require('dialogBox');
																						dialogBox.close({
																						dialogName: 'alert'
																					});
																					

																					
																					
																						//清空剪贴板
																					var clipBoard = api.require('clipBoard');
																					clipBoard.set({
																						value: '逐梦影视' 
																					});																				
																					
																					

																					
																				}
																				
																			}); 				  
			  
																		}
																	  }
																  });

																  



									// 网络状态
								api.addEventListener({
									name:'offline'
								}, function(ret, err){        

									api.toast({
									msg : '网络连接异常',
									duration : 5000,
									location : 'middle' 
									});

									  

								});

								api.addEventListener({
									name:'online'
								}, function(ret, err){        
								
									  api.toast({
									  msg : '已经连接网络',
									  duration : 2000,
									  location : 'middle' 
									  });
										  
														  
								GetData();   //获取数据

										  
								});	







    }
  //  初始化结束








    function GetData(){
	
	

/*
		 api.showProgress({
			  title: '加载中',
			  modal: false
		 });
	*/
	
      api.ajax({
          url: api_url+'/login/login/upgrade_vip.html',
          method: 'get',
          data: {
              values: {
				  key: 'p2piunink',   //安全码
                  uid: localStorage.getItem('user_id')
              }
          }
      },function(ret, err){
          if (ret) {
			if (ret.code == 1) {
			
			
				
                localStorage.setItem('faka_agent',ret.msg['faka_agent']);         //代理设置发卡平台
				
                localStorage.setItem('daili_price',ret.msg['daili_price']);		//代理升级价格
                localStorage.setItem('kami_length',ret.msg['kami_length']);    //卡密长度
           //     localStorage.setItem('headimgurl',ret.msg['headimgurl']);    //用户头像
            //    localStorage.setItem('username',ret.msg['username']);    //用户名
                localStorage.setItem('app_working_mode',ret.msg['app_working_mode']);    //工作模式
                localStorage.setItem('agent_introduction_picture',ret.msg['agent_introduction_picture']);    //代理升级介绍图片
				
                
				

            //    var daili_price = $api.byId('daili_price');
                daili_price.innerHTML = '￥ '+localStorage.getItem('daili_price')+'升级代理 开启轻松赚钱之旅！';
				
				


				

			//代理结束图片
				if(localStorage.getItem('agent_introduction_picture') ==''){
				
				}else{
                var agent_introduction_picture = $api.byId('agent_introduction_picture');
                agent_introduction_picture.innerHTML = '<img src="'+localStorage.getItem('agent_introduction_picture')+'">';
				
				}				


				
				
				

            }//信息获取END
			
				api.hideProgress();   //关闭加载提示
		
          } else {
	
				api.hideProgress();   //关闭加载提示
				
				api.toast({
						msg: '数据加载异常',
						duration: 5000,
					location : 'middle' 
					});


            return;
          }
      });
    }
 










	// 代理激活码发卡
    function faka_agent(){

			if (localStorage.getItem('user_id') ==  1) {			//如果是管理员
			
						api.toast({
							msg: '管理员登录 终止',
							duration: 5000,
							location : 'middle' 
						});
			
			}else {	
					  
					  if (localStorage.getItem('faka_agent') ==  '') {			//如果代理发卡为空
					  

								up_daiil();  //跳转客服
								
							
						}else {	
							
							toBanner(localStorage.getItem('faka_agent'));
						}	
						
			}
    }
	



	// 升级代理 跳转管理员客服
    function up_daiil(){

        api.openWin({
            name: 'admin_service_win',
            url: 'setup/admin_service_win.html'
        });

    }
	


	// 客服
    function go_up_kefu(){


        api.openWin({
            name: 'customer_service_win',
            url: 'setup/customer_service_win.html'
        });

    }
	
	
	




      //访问地址
      function toBanner(url){
        var sys = api.systemType;
        if (sys == 'ios') {
          if (url == '') {
            keFu();
            return;
          }else {
		  
		/*  
		              api.openWin({ 
                name: 'h5',
                url: './h5.html',
                pageParam: {
                    url: url
                }
            });
			
	*/   
		  
            api.openApp({
                   iosUrl: url
           },function(ret,err){
           });
		   
	
		   
          }
        }else {
          // if (url == '') {
          //
          // }else {
          //   api.openApp({
          //       androidPkg: 'android.intent.action.VIEW',
          //       mimeType: 'text/html',
          //       uri: url
          //   }, function(ret, err) {
          //       // if (ret) {
          //       //     alert(JSON.stringify(ret));
          //       // } else {
          //       //     alert(JSON.stringify(err));
          //       // }
          //   });
          //
          // }
          if (url == '') {
            keFu();
            return;
          }else {
            api.openWin({
                name: 'h5',
                url: './h5.html',
                pageParam: {
                    url: url
                }
            });
          }

        }

        // if (url == '') {
        //
        // }else {
        //   api.openWin({
        //       name: 'h5',
        //       url: './h5.html',
        //       pageParam: {
        //           url: url
        //       }
        //   });
        // }
      }


    //充值点卡
    function loginOff(){
      var kami = $api.val($api.byId('kami'));
      if(kami == ''){
        api.toast({
            msg: '激活码还没输入',
            duration: 5000, 
            location : 'middle' 
        });
        return;
      }
      if (user_id<1) {
        alert('请先登录');
        api.openWin({
            name: 'login',
            url: './login.html',
        });
        return;
      }else {
        api.showProgress({
            title: '验证中',
            text: '请稍等',
            modal: false
        });
        api.ajax({
            url: api_url+'/login/login/activation_code.html',
            method: 'get',
            data: {
                values: {
                    uid: localStorage.getItem('user_id'),
                    dianka: kami,
					key: 'p2piunink'   //安全码
                }
            }
        },function(ret, err){
            if (ret) {
                if (ret.code == 0) {
                  api.hideProgress();

		        api.toast({
					msg: ret.msg,
					duration: 5000, 
					location : 'middle' 
				});		  
				  
				  
				  
                  return;
                }else if(ret.code == 8){
				
				api.hideProgress();
				  

		        api.toast({
					msg: ret.msg,
					duration: 5000, 
					location : 'middle' 
				});		  
				  				  

                  localStorage.setItem('power','1');
				   setTimeout("delayed()",1000);  //延迟执行 关闭
				
				
				
				
				}else if (ret.code == 1) {
                  api.hideProgress();
				  

		        api.toast({
					msg: ret.msg,
					duration: 5000, 
					location : 'middle' 
				});		  
				  				  
				  
                  localStorage.setItem('user_time',ret.lasttime);

				   setTimeout("delayed()",1000);  //延迟执行 关闭

                }

            } else {
              api.hideProgress();

		        api.toast({
                      msg: '网络异常',
					duration: 5000, 
					location : 'middle' 
				});		  
	/*			  				  			  
			  
              api.alert({
                  title: '糟糕~',
                  msg: '网络似乎有点问题',
              });
			  */
			  
            }
        });

      }
    }








		//延时执行
	    function delayed(){	
		
                  api.sendEvent({
                    name: 'newLoingdata',
                    extra: {
                    }
                  });
				  
                  api.closeWin();

				}

</script>
</html>
